import Vue from 'vue'
import VueRouter from 'vue-router'
import recommend from "../views/recommend.vue"; //同步路由加载
import guidePage from "../components/public/guidePage.vue"; //同步路由加载



Vue.use(VueRouter)

const routes = [{
        path: '/',
        redirect: "/recommend"
    },
    {
        path: '/login',
        name: "login",
        component: () =>
            import ("../components/base/login.vue"),
        // 独享路由守卫
        // beforeEnter: (to, from, next) => {
        //     let login = window.localStorage.getItem("login");
        //     // 判断登录情况
        //     if (login.length > 0) {
        //         next();
        //         return
        //     } else {
        //         next("/login");
        //     }
        // }
    },
    {
        path: '/userInfo',
        name: "userInfo",
        component: () =>
            import ("../views/userInfo.vue"),
    },
    {
        path: "/guidePage",
        name: "guidePage",
        component: guidePage
    },
    {
        path: "/recommend",
        name: "recommend",
        // 添加路由元信息
        meta: {
            headerNav: true
        },
        component: recommend
    },
    {
        path: "/singer",
        name: "singer",
        meta: {
            headerNav: true
        },
        component: () =>
            import ("../views/singer.vue") //懒加载
    },
    {
        path: "/rank",
        name: "rank",
        meta: {
            headerNav: true
        },
        component: () =>
            import ("../views/rank.vue")
    },
    {
        path: "/rank/ranklist",
        name: "ranklist",
        component: () =>
            import ("../components/rank/ranklist.vue")
    },
    {
        path: "/search",
        name: "search",
        component: () =>
            import ("../components/base/search.vue")
    },
    {
        path: "/newmv",
        name: "newmv",
        meta: {
            headerNav: true
        },
        component: () =>
            import ("../views/newmv.vue")
    },
    { //歌手详情
        path: "/Singerdetails",
        name: "Singerdetails",
        component: () =>
            import ("../components/base/Singerdetails.vue")
    },
    { //歌手详情
        path: "/getinto",
        name: "getinto",
        component: () =>
            import ("../components/base/getinto.vue")
    },
    {
        path: "/transceiver",
        name: "transceiver",
        component: () =>
            import ("../components/base/transceiver.vue")
    },
    {
        path: "/xihuan",
        name: "xihuan",
        component: () =>
            import ("../components/base/xihuan.vue")
    },
    {
        path: "/collection",
        name: "collection",
        component: () =>
            import ("../components/base/collection.vue")
    }

]

const router = new VueRouter({
    mode: 'history',
    base: process.env.BASE_URL,
    routes
})


export default router